﻿@import '../abstracts/variables';

.mud-table {
    color: var(--mud-palette-text-primary);
    background-color: var(--mud-palette-surface);
    border-radius: var(--mud-default-borderradius);
    transition: box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;

    &.mud-table-square {
        border-radius: 0px;
    }

    &.mud-table-outlined {
        border: 1px solid var(--mud-palette-lines-default);
    }
}

.mud-table-container {
    width: 100%;
}

.mud-table-root {
    width: 100%;
    display: table;
    border-spacing: 0;
    border-collapse: collapse;

    & .mud-table-head {
        display: table-header-group;

        & .mud-table-cell {
            color: var(--mud-palette-text-primary);
            font-weight: 500;
            line-height: 1.5rem;
        }
    }

    & .mud-table-body {
        display: table-row-group;

        .mud-table-row:last-child {
            .mud-table-cell {
                border-bottom: none;
            }
        }

        & .mud-table-cell {
            color: var(--mud-palette-text-primary);
        }
    }
}

.mud-table-sort-label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    flex-direction: inherit;
    justify-content: flex-start;

    &:hover {
        color: var(--mud-palette-action-default);

        .mud-table-sort-label-icon {
            opacity: 0.8;
        }
    }

    .mud-table-sort-label-icon {
        font-size: 18px;
        transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,transform 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
        margin-left: 4px;
        user-select: none;
        margin-right: 4px;
        opacity: 0;

        &.mud-direction-desc {
            opacity: 1;
            transform: rotate(180deg);
        }

        &.mud-direction-asc {
            opacity: 1;
            transform: rotate(0deg);
        }
    }
}

.mud-table-toolbar {
    padding-left: 16px;
    padding-right: 8px;
}



.mud-table-cell {
    display: table-cell;
    padding: 16px;
    font-size: 0.875rem;
    text-align: left;
    font-weight: 400;
    line-height: 1.43;
    border-bottom: 1px solid var(--mud-palette-table-lines);
    letter-spacing: 0.01071em;
    vertical-align: inherit;

    & .mud-checkbox {
        margin: -12px;
    }
}

.mud-table-cell-footer {
    color: var(--mud-palette-text-secondary);
    font-size: 0.75rem;
    line-height: 1.3125rem;
}

.mud-table-dense {
    & * .mud-table-row {
        & .mud-table-cell {
            padding: 6px 24px 6px 16px;
        }
        & .mud-table-cell:last-child{
            padding-right: 16px;
        }
    }
}

.mud-table-bordered {
    & .mud-table-container .mud-table-root .mud-table-body {
        & .mud-table-row {
            .mud-table-cell {
                border-right: 1px solid var(--mud-palette-table-lines);
            }
        }
    }
}

.mud-table-sticky-header {
    .mud-table-container {
        overflow-x: auto;
    }

    & * .mud-table-root {
        border-collapse: separate;

        .mud-table-head {
            & * .mud-table-cell:first-child {
                border-radius: var(--mud-default-borderradius) 0px 0px 0px;
            }

            & * .mud-table-cell {
                background-color: var(--mud-palette-surface);
                position: sticky;
                z-index: 1;
                top: 0;
            }
        }
    }
}



.mud-table-row {
    color: inherit;
    display: table-row;
    outline: 0;
    vertical-align: middle;
}

.mud-table-hover {
    & .mud-table-container .mud-table-root .mud-table-body {
        & .mud-table-row:hover {
            background-color: var(--mud-palette-table-hover);
        }
    }
}

.mud-table-striped {
    & .mud-table-container .mud-table-root .mud-table-body {
        & .mud-table-row:nth-of-type(odd) {
            background-color: var(--mud-palette-table-striped);
        }
    }
}

.mud-table-hover.mud-table-striped {
    & .mud-table-container .mud-table-root .mud-table-body {
        & .mud-table-row:nth-of-type(odd):hover {
            background-color: var(--mud-palette-table-hover);
        }
    }
}


.mud-table-cell {
    & > .mud-input-control {
        & > div.mud-input.mud-input-text {
            color: var(--mud-theme-on-surface);
            font-size: 0.875rem;
            margin-top: -14px;
            margin-bottom: -8px;
        }
    }

    & > .mud-select {
        & > .mud-input-control {
            & > div.mud-input.mud-input-text {
                color: var(--mud-theme-on-surface);
                font-size: 0.875rem;
                margin-top: -14px;
                margin-bottom: -8px;
            }
        }
    }
}

.mud-table-cell-align {
    &-left {
        text-align: left;
    }

    &-center {
        text-align: center;
    }

    &-right {
        text-align: right;
        flex-direction: row-reverse;
    }

    &-justify {
        text-align: justify;
    }
}

.mud-table-pagination {
    color: var(--mud-theme-on-surface);
    overflow: auto;
    font-size: 0.875rem;
    display: initial;
}

.mud-table-pagination:last-child {
    padding: 0;
}

.mud-table-pagination-toolbar {
    border-top: 1px solid var(--mud-palette-table-lines);
    height: 52px;
    padding-right: 2px;
}

.mud-table-pagination-spacer{
    flex: 1 1 100%;
}

.mud-table-pagination-caption {
    flex-shrink: 0;
}

.mud-table-pagination-select {
    cursor: pointer;
    margin-left: 10px !important;
    margin-right: 10px !important;
    min-width: 52px;
    margin-top: 0px !important;

    & .mud-select-input {
        margin-top: 0px !important;
    }

    & .mud-input .mud-input-root {
        max-width: 80px;
        cursor: pointer;
        margin-top: 2px;
        border: none;
        font-size: .875rem;
        font-weight: 400;
        line-height: 1.43;
        letter-spacing: .01071em;
        color: var(--mud-theme-on-surface)
    }
}

.mud-table-pagination-actions {
    flex-shrink: 0;
    margin-left: 20px;
}

.mud-table-smalldevices-sortselect{
    display:none;
}

@mixin table-display-smalldevices ($breakpoint) {
    .mud-#{$breakpoint}table {
        .mud-table-root .mud-table-head {
            display: none;
        }

        .mud-table-smalldevices-sortselect {
            display: block;
            padding: 4px 16px 8px;
        }

        .mud-table-body {
            border-top: 1px solid var(--mud-palette-table-lines);
        }

        .mud-table-row {
            display: initial;

            .mud-table-cell:last-child {
                border-bottom: 1px solid var(--mud-palette-table-lines);
            }
        }

        .mud-table-cell {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border: none;
            padding: 14px 16px;
            text-align: left !important;
        }

        &.mud-table-dense {
            & .mud-table-cell {
                padding: 6px 16px;
            }
        }

        .mud-table-cell:before {
            content: attr(data-label);
            font-weight: 500;
            padding-right: 16px;
        }

        &.mud-table-small-alignright .mud-table-cell:before {
            margin-right: auto;
        }

        .mud-table-cell-hide {
            visibility: collapse;
            height: 0;
            padding: 0;
            margin: 0;
        }

        .mud-table-pagination {

            .mud-table-pagination-spacer {
                flex: none;
            }

            .mud-table-pagination-actions {
                .mud-button-root:first-child {
                    display: none;
                }

                .mud-button-root:last-child {
                    display: none;
                }
            }

            .mud-select ~ .mud-table-pagination-caption {
                margin-left: auto;
            }
        }
    }
}

// Table Pagination Flex Wrapper on old as phones
@media (max-width:360px) {
    .mud-table {
        .mud-table-pagination {
            .mud-select {
                margin-left: auto;
                margin-right: -14px;
            }

            .mud-select ~ .mud-table-pagination-caption {
                margin-left: unset !important;
            }
        }
    }
}
@media (max-width:416px) {
    .mud-table {
        .mud-table-pagination {
            .mud-table-pagination-toolbar {
                flex-wrap: wrap;
                padding-top: 16px;
                padding-right: 16px;
                min-height: 100px;
                .mud-table-pagination-actions{
                    margin-left:auto;
                    margin-right:-14px;
                }
            }
        }
    }
}

@media (max-width:$breakpoint-sm) {
    @include table-display-smalldevices("xs-");
}

@media (max-width:$breakpoint-md) {
    @include table-display-smalldevices("sm-");
}

@media (max-width:$breakpoint-lg) {
    @include table-display-smalldevices("md-");
}

@media (max-width:$breakpoint-xl) {
    @include table-display-smalldevices("lg-");
}

@media (min-width:$breakpoint-xl) {
    @include table-display-smalldevices("xl-");
}